{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d32ccd80-b312-4ffb-8d67-5fecad294fd5",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception managing MicrosoftEdge: error sending request for url (https://msedgedriver.azureedge.net/LATEST_RELEASE_139_WINDOWS)\n"
     ]
    }
   ],
   "source": [
    "from selenium import webdriver\n",
    "driver = webdriver.Edge()\n",
    "driver.get(\"https://digquant.com/account\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "78e38542-0179-4830-839b-60d02b274dc8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "从高校到企业，从理论到实践的最后一公里\n"
     ]
    }
   ],
   "source": [
    "from selenium.webdriver.common.by import By\n",
    "from selenium.webdriver.common.keys import  Keys\n",
    "import time \n",
    "import random\n",
    "def simulate_sendkeys(label,str):\n",
    "    label.clear()\n",
    "    time.sleep(0.5)\n",
    "    for i in str:\n",
    "        time.sleep(random.random())\n",
    "        label.send_keys(i)\n",
    "    time.sleep(0.5)\n",
    "# 模拟页面填充内容\n",
    "a = driver.find_element(By.XPATH,\"/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[2]/form/div[1]/div/div[1]/div/input\")\n",
    "simulate_sendkeys(a,\"19860635475\")\n",
    "b = driver.find_element(By.XPATH,\"/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[2]/form/div[2]/div/div[1]/div/input\")\n",
    "simulate_sendkeys(b,\"DigQuant@02\")\n",
    "#爬取网页的内容\n",
    "d = driver.find_element(By.XPATH,\"/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[1]/div\")\n",
    "print(d.text)\n",
    "#模拟点击回车/鼠标点击\n",
    "    #ENTTER回车\n",
    "# label.send_keys(Keys.ENTER)\n",
    "    # 模拟鼠标点击\n",
    "from selenium.webdriver import ActionChains\n",
    "xxx = ActionChains(driver)\n",
    "c = driver.find_element(By.XPATH,\"/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[2]/form/div[3]\")\n",
    "xxx.click(c).perform()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73b4903d-cc35-46ef-8569-79a8f73e68ee",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
